const {app, BrowserWindow, Menu} = require('electron');
const path = require('path');
const template = require('./template')

//Create native application menus and context menus.
//https://www.electronjs.org/docs/latest/api/menu

app.on('ready', () => {
  let win = new BrowserWindow({
    //https://www.electronjs.org/docs/latest/api/browser-window#new-browserwindowoptions
    width: 802,
    height: 550,

    webPreferences: {
      nodeIntegration: true,
      // contextIsolation: true,
      // enableRemoteModule: false,
      // devTools: true
    }
  });

  //template (MenuItemConstructorOptions | MenuItem)[]
  const menu = Menu.buildFromTemplate(template)
  //todo
  // Generally, the template is an array of options for constructing a MenuItem. The usage can be referenced above.
  // You can also attach other fields to the element of the template and they will become properties of the constructed menu items.

  Menu.setApplicationMenu(menu);

  win.loadFile(path.resolve(__dirname, 'index.html'))
});

